/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wwcontrolserver.controls;

import com.phidgets.PhidgetException;
import java.util.ArrayList;
import wwcontrolserver.datarecorders.WWControlServerLogger;
import wwcontrolserver.ifk.AbstractIFK;
import wwcontrolserver.ifk.AnalogInputIFK;
import wwcontrolserver.ifk.DigitalOutputIFK;

/**
 *
 * @author Michael Ferry
 */
public class DigesterHeaterControl extends AbstractSetPointHeaterControl {
    private final AnalogInputIFK HeaterSensorIFK;
    private final int HeaterSensorNum;
    private final DigitalOutputIFK HeaterOutputIFK;
    private final int HeaterOutputNum;
    private final ArrayList<ControlKey> AttachedControls = new ArrayList<ControlKey>();
    
    
    public DigesterHeaterControl(SetPointHeaterControlState InitialControlState, WWControlServerLogger WWCSLog,
            AnalogInputIFK HeaterSensorIFK, int HeaterSensorNum, DigitalOutputIFK HeaterOutputIFK, int HeaterOutputNum) {

        super(InitialControlState, WWCSLog);

        this.HeaterSensorIFK = HeaterSensorIFK;
        this.HeaterSensorNum = HeaterSensorNum;
        this.HeaterOutputIFK = HeaterOutputIFK;
        this.HeaterOutputNum = HeaterOutputNum;
        
        AttachedControls.add(new ControlKey(HeaterSensorIFK.GetIfkSerial()));
        AttachedControls.add(new ControlKey(HeaterSensorIFK.GetIfkSerial(),HeaterSensorNum));
        AttachedControls.add(new ControlKey(HeaterOutputIFK.GetIfkSerial()));
        AttachedControls.add(new ControlKey(HeaterOutputIFK.GetIfkSerial(),HeaterOutputNum));
    }
    @Override
    public ArrayList<ControlKey> GetListOfControlKeys(){
        return AttachedControls;
    }
    
    @Override
    public double GetCurrentTemperature() throws Exception {
        return HeaterSensorIFK.GetSensorComputedValue(HeaterSensorNum);
    }
    @Override
    protected void SetHeaterState(boolean HeaterState) throws Exception{
        HeaterOutputIFK.SetOutputState(HeaterOutputNum, HeaterState);
    }
    @Override
    public boolean GetHeaterState() throws Exception{
        return HeaterOutputIFK.GetOutputState(HeaterOutputNum);
    }
//    @Override
//    public void ShutdownControl(){
//        SetControlActivityState(false);
//    }
}
